package com.headfirst.BehaviorMode.command.remote.version2;

import com.headfirst.BehaviorMode.command.remote.version2.equipment.CeilingFan;

public class CeilingFanLowCommand implements Command {
    private CeilingFan ceilingFan;
    private int previewSpeed;

    public CeilingFanLowCommand(CeilingFan ceilingFan) {
        this.ceilingFan = ceilingFan;
    }

    @Override
    public void execute() {
        previewSpeed = ceilingFan.getSpeed();
        ceilingFan.low();
    }

    @Override
    public void undo() {
        if (previewSpeed == CeilingFan.HIGH) {
            ceilingFan.high();
        } else if (previewSpeed == CeilingFan.MEDIUM) {
            ceilingFan.medium();
        } else if (previewSpeed == CeilingFan.LOW) {
            ceilingFan.low();
        } else if (previewSpeed == CeilingFan.OFF) {
            ceilingFan.off();
        }
    }
}
